package com.hdax.dm.mapstructs;

import com.hdax.dm.dtos.scheduler.ChooseSeatScheduleDto;
import com.hdax.dm.entity.scheduler.DmSchedulerSeat;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public abstract class SeatInfoDtoMapper {

    @Mappings({
            @Mapping(target = "areaLevel",expression = "java(longToString(source.getAreaLevel()))")
    })
    public abstract ChooseSeatScheduleDto.SeatInfo toTarget(DmSchedulerSeat source);
    public abstract List<ChooseSeatScheduleDto.SeatInfo> toTargetList(List<DmSchedulerSeat> sources);

    public String longToString(Long areaLevel){
        if(areaLevel == 1L) return "A";
        if(areaLevel == 2L) return "B";
        if(areaLevel == 3L) return "C";
        return "";
    }
}
